package com.hulushuju.core.net.proxy;

import lombok.AllArgsConstructor;

import java.net.InetSocketAddress;

/**
 * @Author: Hanjiafeng
 * @Date: 2019-05-27
 * @Desc:
 */
@AllArgsConstructor
public class Proxy {
    private String ip;
    private int port;
    private String username;
    private String password;

    /**
     * 初始化java Proxy
     *
     * @return java.net.Proxy, 类型为HTTP
     */
    public java.net.Proxy initProxy() {
        return new java.net.Proxy(java.net.Proxy.Type.HTTP, new InetSocketAddress(ip, port));
    }

    /**
     * 初始化代理认证器
     *
     * @return 代理认证器
     */
    public ProxyAuthenticator initAuthenticator() {
        return new ProxyAuthenticator(username, password);
    }
}
